package com.code.day15DuoXianC.Dielock;

public class Mylock implements Runnable {


    private boolean flag;


    public Mylock(boolean flag) {
        this.flag = flag;
    }

    @Override
    public void run() {
        if (flag) {
            synchronized (LockA.lockA) {
                System.out.println("if........locka");
                synchronized (LockB.lockB) {
                    System.out.println("if........lockB");
                }
            }
        } else {
            synchronized (LockB.lockB) {
                System.out.println("else........lockB");
                synchronized (LockA.lockA) {
                    System.out.println("else........locka");
                }
            }
        }
    }
}
